package com.secondriver.url.match;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import com.secondriver.url.filter.match.URLPatternMatch;
import com.secondriver.url.filter.match.groovy.DefalutURLPatternMatch;
import com.secondriver.url.filter.match.groovy.SimpleURLPatternMatch

@RunWith(value=Parameterized.class)
class TestSimpleURLPatternMatch {


	def static URLPatternMatch match;

	def static urls =['/a*c', '/*bc', '/ab*' , 'abc', '/abc/*/123', '/**/abc'] as HashSet;

	def request;

	def result;

	public TestSimpleURLPatternMatch(String request, boolean result ) {
		this.request=request;
		this.result=result;
	}

	@Parameters
	public static Collection data(){
		return		[
			['a.c', true] as Object[],
			['a/c', false] as Object[],
			['/a1c', true] as Object[],
			['/1bc', true] as Object[],
			['/ab1', true] as Object[],
			['/abc', true] as Object[],
			['/123', false] as Object[],
			['/abc/xyz/123', true] as Object[],
			['/abc/xyz/xyz/123', false] as Object[],
			['abc', true] as Object[],
			['/123/abc', true] as Object[],
			['/123/123/abc', false] as Object[],
			['123/123/abc', false] as Object[]
		];
	}

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		match=new SimpleURLPatternMatch();
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Test
	public void testSimple(){
		assertEquals(result, match.isPass(request, urls));
	}
}
